import { Observable } from './Observable'
export class Subject extends Observable {
  observers: any[] = []
  _subscribe: any = (subscribe: any) => {
    this.observers.push(subscribe)
  }
  next(value: any) {
    for (const subscriber of this.observers) {
      subscriber.next(value)
    }
  }
  error(error: any) {
    for (const subscriber of this.observers) {
      subscriber.error(error)
      subscriber.complete()
    }
  }
  complete() {
    for (const subscriber of this.observers) {
      subscriber.complete()
    }
  }
}